package com.lbt.framework.general;

import java.util.ArrayList;
import java.util.List;

/**
 * 搜索参数工具类
 *
 * @author mo_yq5
 * @since 2016年4月10日
 */
public class SearchingFactory {

	public static Sorting createSorting(String field, boolean isDesc) {
		List<Sort> sorts = new ArrayList<Sort>();
		sorts.add(new Sort(field, true));
		Sorting sorting = new Searching();
		sorting.setSorts(sorts);
		return sorting;
	}
	
	public static Sorting createSorting(String field) {
		return createSorting(field, false);
	}
	
	public static Searching createSearching(String sortField, int pageSize) {
		return createSearching(sortField, false, pageSize);
	}
	
	public static Searching createSearching(String sortField, boolean isDesc, int pageSize) {
		Searching si = new Searching();
		si.setPageSize(pageSize);
		List<Sort> sorts = new ArrayList<Sort>();
		sorts.add(new Sort(sortField, isDesc));
		si.setSorts(sorts);
		return si;
	}
}
